<%-- 
    Document   : AddMonthlySal
    Created on : May 20, 2014, 11:22:26 AM
    Author     : Mukesh
--%>

<%@page import="SalaryComponent.SalaryComponentBean"%>
<%@page import="SalaryComponent.EmpSalDetailsBean"%>
<%@page import="SalaryComponent.EmpSalaryBean"%>
<%@page import="ExamType.ExamTypeBean"%>
<%@page import="Course.CourseList"%>
<%@page import="Course.CourseBean"%>
<%
    try {
        if (session.getAttribute("uid") != null) {
            if (session.getAttribute("Employee_Salary").toString().equals("1")) {
%>
<%String to = "", status = "", msg = "";%>
<%@page import="java.util.Iterator"%>
<%@page import="java.util.Vector"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <title>Ramgovind Automated System</title>

        <link rel="stylesheet" href="/RIT/css/bootstrap.css">
        <link rel="stylesheet" href="/RIT/css/bootstrap-responsive.css">
        <link rel="stylesheet" href="/RIT/css/jquery.fancybox.css">
        <link rel="stylesheet" href="/RIT/css/style.css">
        <link rel="stylesheet" href="/RIT/css/iconfont.css">
        <link rel="stylesheet" href="/RIT/css/bootstrap.datepicker.css">
        <style>
            .cool{
                color: rgb(151, 151, 151);
                font-weight: bold;
                padding-left: 5px;
                display: block;
                background: #f5f5f5;
                border-bottom: 1px solid #C2C2C2;
                margin-bottom: 7px;
            }
            .co{
                padding-left: 5px;
                color:#9E9E9E;
                display: block;
            }
        </style>
        <script src="../../ajax/ajax.js"></script>

        <script>
            function cal(inp, i, out, subtotal) {
                var total = 0;
                for (var j = 0; j < i; j++) {

                    var val = parseFloat(document.getElementById(inp + j).value);
                    //alert(isNaN(val));
                    if (!isNaN(val)) {
                        var whtage = parseFloat(document.getElementById(inp + j).title);
                        total = total + ((parseFloat(val) / parseFloat(subtotal)) * parseFloat(whtage));
                    }
                    document.getElementById(out).value = total;
                }
            }
            function hideShowPayMode(val) {
                if (val == 1) {
                    document.getElementById('bank').disabled = true;
                    document.getElementById('branch').disabled = true;
                    document.getElementById('cheque').disabled = true;
                    document.getElementById('hs').style.display = "none";
                }
                else {
                    document.getElementById('bank').disabled = false;
                    document.getElementById('branch').disabled = false;
                    document.getElementById('cheque').disabled = false;
                    document.getElementById('hs').removeAttribute('style');
                }
            }
        </script>
    </head>
    <body>
        <%@include file="/topheader.html" %>
        <%@include file="/servicesheader.html" %>
        <div class="main">
            <div class="container-fluid">
                <%@include file="/Services/Payroll/payrollsidenav.html" %>
                <div class="content">
                    <%if (session.getAttribute("status") != null) {
                            status = session.getAttribute("status").toString();
                            msg = session.getAttribute("msg").toString();
                    %>
                    <div class="alert alert-info alert-block">
                        <a class="close" data-dismiss="alert" href="#"><img src="/RIT/img/mclose.png"></a>
                        <h4 class="alert-heading"> <%=status%></h4>
                        <%=msg%>

                    </div>
                    <%session.removeAttribute("status");
                            session.removeAttribute("msg");
                        }%>
                    <div class="row-fluid">
                        <div class="span12">
                            <div class="box">
                                <div class="box-head">
                                    <h3>Add Number</h3>

                                    <span style="float: right; margin: 5px 20px 0 0; ">Employee Name : <%=request.getParameter("emp")%></span>
                                </div>
                                <form action="/RIT/AddMonthlySal" method="post" class='validate form-horizontal'>
                                    <div class="box-content">
                                        <!---Form Start....-->

                                        <div id="lside" style="float: left; margin-top: 10px;">
                                            <div class="control-group">
                                                <label for="year" class="control-label">Year<span style="color:red">*</span></label>
                                                <div class="controls">
                                                    <select name="year" id="year" class='{required:true}'>
                                                        <option value="">Select Year</option>
                                                        <%{
                                                                for (int i = 0; i < 10; i++) {%>
                                                        <option value="<%= 2014 + i%>"><%= 2014 + i%></option>
                                                        <%}
                                                            }%>
                                                    </select>
                                                    <input type="hidden" value="<%=request.getParameter("empid")%>" name="empid">
                                                </div>
                                            </div>
                                            <div class="control-group">
                                                <label for="month" class="control-label">Month<span style="color:red">*</span></label>
                                                <div class="controls">
                                                    <select name="month" id="month" class='{required:true}'>
                                                        <option value="">Select Month</option>
                                                        <%{
                                                                String[] month = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
                                                                for (int i = 0; i < 12; i++) {%>
                                                        <option value="<%=i + 1%>"><%=month[i]%></option>
                                                        <%}
                                                            }%>
                                                    </select>
                                                </div>
                                            </div>
                                            <div class="control-group">
                                                <label for="wdays" class="control-label">Working Days<span style="color:red">*</span></label>
                                                <div class="controls">
                                                    <input type="text" name="wdays" id="wdays" class="required number" onblur="salcalc()">
                                                </div>
                                            </div>
                                            <div class="control-group">
                                                <label for="total" class="control-label">Total Rs.<span style="color:red">*</span></label>
                                                <div class="controls">
                                                    <input type="text" name="total" id="total" class="required number">
                                                </div>
                                            </div>
                                            <div class="control-group">
                                                <label for="pmode" class="control-label">Pay Mode<span style="color:red">*</span></label>
                                                <div class="controls">
                                                    <strong>
                                                        <select name="pmode" id="pmode" class='input-square' onchange="hideShowPayMode(this.value)">
                                                            <option value="">Select</option>
                                                            <option value="1">Cash</option>
                                                            <option value="2">Cheque</option>
                                                            <option value="3">Demand Draft</option>
                                                        </select>
                                                    </strong>
                                                </div>
                                            </div>
                                                    <div id="hs" style="display: none;">
                                                <div class="control-group">
                                                    <label for="cheque" class="control-label">Cheque No<span style="color:red">*</span></label>
                                                    <div class="controls">
                                                        <input type="text" name="cheque" id="cheque" class="required number">
                                                    </div>
                                                </div>
                                                <div class="control-group">
                                                    <label for="bank" class="control-label">Bank <span style="color:red">*</span></label>
                                                    <div class="controls">
                                                        <input type="text" name="bank" id="bank" class="required">
                                                    </div>
                                                </div>
                                                <div class="control-group">
                                                    <label for="branch" class="control-label">Branch<span style="color:red">*</span></label>
                                                    <div class="controls">
                                                        <input type="text" name="branch" id="branch" class="required">
                                                    </div>
                                                </div>
                                            </div>

                                        </div>
                                        <div id="rside" style="float: left; margin-left: 120px; margin-top: 10px; width: 300px;">
                                            <span class="cool">Salary Structure</span>
                                            <%
                                                float tsal = 0, tded = 0, tearn = 0;
                                                int EmpId = Integer.parseInt(request.getParameter("empid"));

                                                Vector list = EmpMonthlySal.Query.getMonthSalDetail(EmpId);
                                                Iterator it = list.iterator();
                                                while (it.hasNext()) {
                                                    EmpSalaryBean esb = (EmpSalaryBean) it.next();
                                                    EmpSalDetailsBean esdb = esb.getEmpSalDetailsBean();
                                                    SalaryComponentBean ecb = esb.getSalaryComponentBean();
                                                    out.println("<span class='co'>" + ecb.getSalaryComponent() + " : " + esdb.getAmount() + " </span>");
                                                    tsal = esb.getTotalSal();
                                                    tded = esb.getTotalDeduction();
                                                    tearn = esb.getTotalEarning();
                                                }
                                                out.println("<input type='hidden' id='tsal' value='"+tsal+"'>");
                                                out.println("<span class='cool'></span>");
                                                out.println("<span class='co'> Total Salary : " + tsal + " </span>");
                                                out.println("<span class='co'> Total Deduction : " + tded + " </span>");
                                                out.println("<span class='co'> Total Earning : " + tearn + " </span>");
                                            %>
                                        </div>

                                        <!---Form Ends....-->
                                    </div>
                                    <div class="form-actions">
                                        <input type="submit" class='btn btn-primary'value="update">
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>	
            </div>
        </div>
        <script src="/RIT/js/jquery.js"></script>
        <script src="/RIT/js/less.js"></script>
        <script src="/RIT/js/bootstrap.min.js"></script>
        <script src="/RIT/js/jquery.uniform.min.js"></script>
        <script src="/RIT/js/bootstrap.timepicker.js"></script>
        <script src="/RIT/js/bootstrap.datepicker.js"></script>
        <script src="/RIT/js/chosen.jquery.min.js"></script>
        <script src="/RIT/js/jquery.fancybox.js"></script>
        <script src="/RIT/js/plupload/plupload.full.js"></script>
        <script src="/RIT/js/plupload/jquery.plupload.queue/jquery.plupload.queue.js"></script>
        <script src="/RIT/js/jquery.cleditor.min.js"></script>
        <script src="/RIT/js/jquery.inputmask.min.js"></script>
        <script src="/RIT/js/jquery.tagsinput.min.js"></script>
        <script src="/RIT/js/jquery.mousewheel.js"></script>
        <script src="/RIT/js/jquery.textareaCounter.plugin.js"></script>
        <script src="/RIT/js/ui.spinner.js"></script>
        <script src="/RIT/js/jquery.jgrowl_minimized.js"></script>
        <script src="/RIT/js/jquery.form.js"></script>
        <script src="/RIT/js/jquery.validate.min.js"></script>
        <script src="/RIT/js/bbq.js"></script>
        <script src="/RIT/js/jquery-ui-1.8.22.custom.min.js"></script>
        <script src="/RIT/js/jquery.form.wizard-min.js"></script>
        <script src="/RIT/js/jquery.cookie.js"></script>
        <script src="/RIT/js/jquery.metadata.js"></script>
        <script src="/RIT/js/custom.js"></script><script src="/RIT/js/demo.js"></script>
        <script src="/RIT/js/iconfont.js"></script>
        <script>
            function salcalc(){
                
                var tsal =parseInt(document.getElementById('tsal').value);
                var days =parseInt(document.getElementById('wdays').value);
                var t=(tsal/30)*days;
                document.getElementById('total').value=t;
            }
        </script>
    </body>
</html>

<%} else {
%>
<script type="text/javascript">
                                                            alert("You Are Not Authorised");
                                                            window.history.back();
</script>
<%             }
        } else {
            request.setAttribute("msg", "You Are Not Authorised! Please Contact to System Administrator!");
            request.setAttribute("value", "0");
            getServletContext().getRequestDispatcher("/index.jsp").forward(request, response);
        }
    } catch (Exception e) {
        request.setAttribute("msg", "Please Contact to System Administrator!");
        request.setAttribute("value", "0");
        getServletContext().getRequestDispatcher("/index.jsp").forward(request, response);
    }
%>

